<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>添加项目</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="../../css/index.css">
		<link rel="stylesheet" href="../../layui/css/layui.css" />
</head>
<body>

 <div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">
    <input type="hidden" id="projectid" name="projectid" autocomplete="off" class="layui-input">
    <div class="layui-form-item">
      <label class="layui-form-label">项目名称</label>
      <div class="layui-input-inline">
        <input type="text" id="projectname" name="projectname" lay-verify="required" placeholder="项目名称不能为空" autocomplete="off" class="layui-input">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">项目组别</label>
      <div class="layui-input-inline">
        <select name="agendtype" id="agendtype" lay-verify="required">
          <option value="">请选择组别</option>
          <option value="1">男子组</option>
          <option value="2">女子组</option>
        </select>
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">项目类别</label>
      <div class="layui-input-inline">
        <select name="itemcategory" id="itemcategory" lay-verify="required">
          <option value="">请选择项目类别</option>
          <option value="1">个人赛</option>
          <option value="2">集体赛</option>
        </select>
      </div>
    </div>
     <div class="layui-form-item">
      <label class="layui-form-label">限制人数</label>
      <div class="layui-input-inline">
        <input type="text" id="prolimitnum" name="prolimitnum" lay-verify="required"  autocomplete="off" class="layui-input">
      </div>
    </div>
    
    <div class="layui-form-item">
      <label class="layui-form-label">分组人数</label>
      <div class="layui-input-inline">
        <input type="text" id="grouplimitnum" name="grouplimitnum" lay-verify="required"  autocomplete="off" class="layui-input">
      </div>
    </div>
    
    <div class="layui-inline">
     <label class="layui-form-label">报名开始时间</label>
     <div class="layui-input-inline">
       <input type="text" name="starttime" id="starttime"  placeholder="yyyy-MM-dd" lay-verify="required" autocomplete="off" class="layui-input">
     </div>
   </div>
   <div class="layui-inline">
    	<label class="layui-form-label">报名结束时间</label>
     <div class="layui-input-inline">
       <input type="text" name="endtime" id="endtime" placeholder="yyyy-MM-dd" lay-verify="required" autocomplete="off" class="layui-input">
     </div>
   </div>
    <div class="layui-form-item layui-form-text">
	    <label class="layui-form-label">项目简介</label>
	    <div class="layui-input-block">
	      <textarea name="showitem" id="showitem" placeholder="请输入项目简介" class="layui-textarea" style="width:190px;"></textarea>
	    </div>
	  </div>
     <div class="layui-form-item">
      <label class="layui-form-label">备注</label>
      <div class="layui-input-inline">
        <input type="text" id="note" name="note" lay-verify="required"  autocomplete="off" class="layui-input">
      </div>
    </div>
    
    <div class="layui-form-item layui-hide">
      <input type="button" lay-submit lay-filter="layuiadmin-app-form-submit" id="layuiadmin-app-form-submit" value="确认添加">
      <input type="button" lay-submit lay-filter="layuiadmin-app-form-edit" id="layuiadmin-app-form-edit" value="确认编辑">
    </div>
  </div>

 <script type="text/javascript" src="../../layui/layui.all.js" charset="utf-8"></script> 

<script type="text/javascript">
 layui.use(['table','jquery','upload','form','laydate','layer'], function(){
  var table = layui.table;
  var $ = layui.jquery;
  var form=layui.form;
  var layer = layui.layer,laydate = layui.laydate,upload = layui.upload;
  
  
	  //执行一个laydate实例
	  laydate.render({
	    elem: '#starttime' //指定元素
	    ,trigger : 'click'
	  });
	  
	  laydate.render({
	    elem: '#endtime' //指定元素
	    ,trigger : 'click'
	  });
  
  
    //监听提交,添加事件
    form.on('submit(layuiadmin-app-form-submit)', function(data){
      var field = data.field; //获取提交的字段
      var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引  
 			
			var param = "?projectid=" + field.projectid + "&projectname=" + field.projectname + "&agendtype=" + field.agendtype + "&itemcategory="
						+ field.itemcategory + "&prolimitnum=" + field.prolimitnum + "&grouplimitnum=" + field.grouplimitnum + 
						"&note=" + field.note + "&staretime=" + field.starttime + "&endtime=" + field.endtime+ "&showitem=" + field.showitem;
			//alert(param)
			$.ajax({
				url:"../../MentalSociety/modifychiefMental" + param,
				type:"POST",
				data:null,
				dataType : "json",
				xhrFields :{
					withCredentials: true
				},
				contentType:'application/json;charset=UTF-8',
				success:function(e){
					//alert(e.msg)
					if(e.code == 0){
						layer.msg(e.msg,{icon:6}); 
					}else{
						layer.msg(e.msg,{icon:5});
						return;
					}
					
					setTimeout(function(){
						parent.layer.close(index); //再执行关闭
						parent.layui.table.reload('project'); //重载表格
      					 
					},1*1000)
					
				},
				error:function(e){
					layer.msg(e.msg,{icon:5});
					
				}
			})
      	return false;
    });
  
  
});
</script>
</body>
</html>